package com.dangdang.spel.adviser;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dangdang.spel.exception.BusinessException;
import com.dangdang.spel.rest.RestfulDto;

@ControllerAdvice
public class ExceptionController {

	@ResponseBody
    @ExceptionHandler({BusinessException.class}) //指定拦截异常的类型
	public RestfulDto error(BusinessException e) {
		return RestfulDto.failed(e.getMessage());
	}
}
